SERVO MOTOR INTERFACING WITH 8051
A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal.
Synopsis

A Servo is a small device that has an output shaft. This shaft can be positioned to specific angular positions by sending the servo a coded signal. As long as the coded signal exists on the input line, the servo will maintain the angular position of the shaft. As the coded signal changes, the angular position of the shaft changes. In practice, servos are used in radio controlled airplanes to position control surfaces like the elevators and rudders. They are also used in radio controlled cars, puppets, and of course, robots.

Description

Servos are DC motors with built in gearing and feedback control loop circuitry. And no motor drivers required. They are extremely popular with robot, RC plane, and RC boat builders. Most servo motors can rotate about 90 to 180 degrees. Some rotate through a full 360 degrees or more. The GPIO pin of AT89S51 microcontroller is set as the output pin to provide control signal to the servo motor. Before connecting to the control wire of servo, the output from the microcontroller is fed through a comparator IC (LM324) so that the signal is protected from any loss due to overloading. However, servos are unable to continually rotate, means they can't be used for driving wheels, unless they are modified, but their precision positioning makes them ideal for robot legs and arms, rack and pinion steering etc. How to use a servo, simply connect the black wire to ground, the red to a 4.8-6V source, and the yellow/white wire to a signal generator (such as from your microcontroller). Vary the square wave pulse width from 1-2 ms and your servo is now position/velocity controlled. Pulse width modulation (PWM) is a powerful technique for controlling analog circuits with a processor's digital outputs. The general concept is to simply send an ordinary logic square wave to your servo at a specific wave length, and your servo goes to a particular angle. The wavelength directly maps to servo angle.


Basic working concept of servo motors


Proteus design for Servo Motor interfacing with 8051


Orcad design for Servo Motor interfacing with 8051


Servo Motor interfacing with 8051

/*  Name     : main.c
 *  Purpose  : Source code for Servo Motor Interfacing with AT89C52.
 *  Author   : Gemicates
 *  Date     : 2014-01-19
 *  Website  : www.gemicates.org
 *  Revision : None
 */

                                                         // Program to rotate servo by 5 degree from previous position starting from 0 degree

                                                         // 0 degree = 700us 
                                                         // 180 degree = 5500us 
                                                         // Timer1 pulse after 50us	-23

#include <REGX52.H>
sbit output=P1^0;  		                                 // Output to motor
int count; 
        
void delay(unsigned int msec)                            // Function for delay
{ 
	int i,j;
	for(i=0;i<msec;i++)
		for(j=0;j<1275;j++);
} 

void timer(int msec)	                                 // Function for timer
{
	int i;
	TR1=1;
	for(i=0;i<msec;i++)
	{
		while(TF1==0);
		TF1=0;
	}
	TR1=0;
}
void main()
{
	int i;
	TMOD=0x20; 		                                    // Mode2
	TH1= -23;		                                    // 50usec timer
	output=0;
	count=14;
	while(1)
	{
		if(count>=100)
			count=14;
		else
			count=count+5;
		for(i=0;i<200;i++)
		{
			output=1;
			timer(count);		 
			output=0;
			timer(360);
		}	
		delay(100);	
	}
}
Video

Interfacing of Servo Motor with 8051

Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close